package com.bawei.mall.search.service.impl;

import com.bawei.mall.search.domain.Book;
import com.bawei.mall.search.service.BookRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class BookService {

    @Autowired
    private BookRepository bookRepository;

    @Transactional(propagation = Propagation.REQUIRED)
    public void saveBookRequiredPropagation(Book book) {
        bookRepository.saveBook(book);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void saveBookRequiresNewPropagation(Book book) {
        bookRepository.saveBook(book);
    }
}
